<template>
	<view class="work-container">
		<uni-list>
			<uni-list-item v-for="(item, index) in list" :key="item.vbillcode" link @click="onClick(item)">
				<view slot="body">
					<text class="title-text">
						单号：{{ item.vbillcode }}，日期：{{ formateDate(item.createTime) }}
					</text>
					<br>
					<text class="multiline-text">
						<!--{{ item.detailList && item.detailList.length
							? item.detailList.map(detail => `产品：${detail.name} [数量：${detail.nastnum}]`).join('；')
							: '' }} -->
						产品：{{item.productName}}；排产数：{{item.dispachNum}}；完成数：{{item.completedNum}}
					</text>
				</view>
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import {
		g2list
	} from "@/api/glue_injection/get_list.js"
	import {
		parseTime
	} from "@/utils/ruoyi.js"
	export default {
		onLoad() {

		},
		data() {
			return {
				list: []
			}
		},
		methods: {
			async getVbillCodeList() {
				// 假数据
				this.list = [{
						vbillcode: 'A001',
						createTime: '2024-06-01 10:00:00',
						pkMaterial: 6,
						dispach_num: 6,
						completed_num: 6,
						detailList: [{
								nastnum: 10,
								name: '产品A'
							},
							{
								nastnum: 5,
								name: '产品B'
							}
						]
					},
					{
						vbillcode: 'A002',
						createTime: '2024-06-02 11:30:00',
						pkMaterial: 6,
						dispach_num: 6,
						completed_num: 6,
						detailList: [{
							nastnum: 8,
							name: '产品C'
						}]
					},
					{
						vbillcode: 'A003',
						createTime: '2024-06-03 09:15:00',
						pkMaterial: 6,
						dispach_num: 6,
						completed_num: 6,
						detailList: [{
								nastnum: 12,
								name: '产品D'
							},
							{
								nastnum: 7,
								name: '产品E'
							}
						]
					}
				];
			},
			async getCWlist() {
				//获取2车间-浇注车间的检验单
				const ppw = await g2list(1,100,2);
				// console.log(ppw)
				this.list = ppw.data.list;
			},
			onClick(item) {
				uni.setStorageSync('currentDetail', item);
				// console.log(item)
				// console.log(uni.getStorageSync('currentDetail'))
				// 等数据存储后再跳转
				uni.navigateTo({
					url: '/pages/glue_injection/detail'
				});
			},
			formateDate(ttt){
				return parseTime(ttt).slice(2, 10);
			}
		},
		mounted() {
			this.getCWlist();
		}
	}
</script>

<style lang="scss">
	.title-text {
		font-size: 28rpx;
		white-space: normal;
		word-wrap: break-word;
	}

	.multiline-text {
		font-size: 24rpx;
		color: #777;
		white-space: normal;
		word-wrap: break-word;
	}
</style>